package com.cchip.cloud.system;

import android.content.Context;
import android.content.SharedPreferences;

public class Config {
	public static final String FILE_NAME = "config";

	private static SharedPreferences sp = null;
	private static final String KEY_SAVE_ACCOUNT = "key.save.account";
	private static final String KEY_AUTO_LOGIN = "key.auto.login";
	private static final String KEY_USERNAME = "key.username";
	private static final String KEY_PASSWORD = "key.password";
	private static final String KEY_ROOM_ID = "key.room.id";
	private static final String KEY_ROOM_PASSOWRD = "key.room.password";

	public static void init(Context context) {
		sp = context.getSharedPreferences(FILE_NAME, 0);
	}

	public static String getHttpHost() {
		return "202.104.174.99";
	}

	public static String getRsHost() {
		return "202.104.174.99:4569";
	}

	public static boolean hasSavedAccount() {
		return sp.getBoolean(KEY_SAVE_ACCOUNT, false);
	}

	public static void setSavedAccount(boolean saved) {
		sp.edit().putBoolean(KEY_SAVE_ACCOUNT, saved).commit();
	}

	public static boolean isAutoLogin() {
		return sp.getBoolean(KEY_AUTO_LOGIN, false);
	}

	public static void setAutoLogin(boolean auto) {
		sp.edit().putBoolean(KEY_AUTO_LOGIN, auto).commit();
	}

	public static String getUsername() {
		return sp.getString(KEY_USERNAME, null);
	}

	public static void setUsername(String username) {
		sp.edit().putString(KEY_USERNAME, username).commit();
	}

	public static String getPassword() {
		return sp.getString(KEY_PASSWORD, null);
	}

	public static void setPassword(String password) {
		sp.edit().putString(KEY_PASSWORD, password).commit();
	}

	public static String getRoomId() {
		return sp.getString(KEY_ROOM_ID, "10000000");
	}

	public static void setRoomId(String id) {
		sp.edit().putString(KEY_ROOM_ID, id).commit();
	}

	public static String getRoomPassword() {
		return sp.getString(KEY_ROOM_PASSOWRD, "");
	}

	public static void setRoomPassword(String password) {
		sp.edit().putString(KEY_ROOM_PASSOWRD, password).commit();
	}

}
